package com.gxa.web_admin.controller.accesscontroller;

import com.gxa.common.R;
import com.gxa.modules.pojo.AlarmRules;
import com.gxa.modules.pojo.ProjectInfo;
import com.gxa.modules.service.accessservice.AlarmRulesService;
import com.gxa.modules.service.accessservice.ProjectInfoService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "projectInfo")
@Api(value = "项目信息管理模块",tags = "项目信息管理API")
public class ProjectInfoController {

    @Autowired
    private ProjectInfoService projectInfoService;

    /**
     * 查询所有项目信息
     * @return 返回所有项目信息
     */
    @RequestMapping(value = "selecProjectInfo",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有项目信息接口",notes = "根据传入信息查询项目信息",httpMethod = "GET", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "projectName",value = "项目名称",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "projectNumber",value = "项目编号",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "projectStatusId",value = "项目状态id",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "page",value = "当前页码",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "size",value = "每页显示条数",paramType = "query",dataType = "String",required = true)
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R selecProjectInfo(String projectName, String projectNumber,String projectStatusId,String page,String size){

        return projectInfoService.selecProjectInfo(projectName,projectNumber,projectStatusId,page,size);
    }


    /**
     * 新增告警规则
     * @return 返回成功
     */
    @RequestMapping(value = "insertProjectInfo",method = RequestMethod.POST)
    @ApiOperation(value = "新增项目信息接口",notes = "新增项目信息",httpMethod = "POST", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R insertProjectInfo(@RequestBody @ApiParam(name = "insertProjectInfoJson",
            value = "项目名称、项目编号、项目类型id、项目地址、项目状态id、预计上线时间",required = true)
                                       ProjectInfo projectInfo){

        return projectInfoService.insertProjectInfo(projectInfo);
    }


    /**
     * 删除项目信息
     * @return 返回删除成功
     */
    @RequestMapping(value = "deleteProjectInfo",method = RequestMethod.POST)
    @ApiOperation(value = "删除项目信息接口",notes = "根据传入id删除项目信息",httpMethod = "POST", response = String.class)
    @ApiImplicitParam(name = "projectInfoId",value = "项目信息id",paramType = "query",dataType = "String",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteProjectInfo(String projectInfoId){

        return projectInfoService.deleteProjectInfo(projectInfoId);
    }

    /**
     * 修改项目信息
     * @return 返回成功
     */
    @RequestMapping(value = "updateProjectInfo",method = RequestMethod.POST)
    @ApiOperation(value = "修改项目信息接口",notes = "修改项目信息",httpMethod = "POST", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateProjectInfo(@RequestBody @ApiParam(name = "updateProjectInfoJson",
            value = "项目id、项目名称、项目编号、项目类型id、项目地址、项目状态id、预计上线时间",required = true)
                                           ProjectInfo projectInfo){

        return projectInfoService.updateProjectInfo(projectInfo);
    }


}
